import { Button } from 'antd';
import { download } from '@hdtd/utils';
const Download = () => {
  const url1 = 'http://localhost:3000/api/downloadFile?filePath=/images/big2.png';
  const url2 =
    'http://192.168.8.11/elsapi/getStaticResources/uploadPath/elsDecorationFile/dataBaseFile/thumbnail/thumb_%E5%AE%89%E5%85%A8%E5%B8%BD%E6%AF%8F%E6%97%A5%E5%B7%A1%E6%9F%A5%E6%88%AA%E5%9B%BE20250327113516.jpg';
  const url3 = '/js/config.js';
  const blob1 = new Blob([]);

  const fetchLoad = async () => {
    try {
      const res = await fetch('http://localhost:3000/api/downloadFile?filePath=/images/big20.png', {
        method: 'HEAD'
      });
      // const res = await fetch(
      //   'http://192.168.8.11/elsapi/getStaticResources/uploadPath/elsDecorationFile/dataBaseFile/thumbnail/thumb_%E5%AE%89%E5%85%A8%E5%B8%BD%E6%AF%8F%E6%97%A5%E5%B7%A1%E6%9F%A5%E6%88%AA%E5%9B%BE20250327113516.jpg',
      //   {
      //     method: 'HEAD'
      //   }
      // );
      console.log(res);
    } catch (error) {
      console.log(error, 'err');
    }
  };

  return (
    <div>
      <Button onClick={() => download(url1, 'url1')}>下载1</Button>
      <Button onClick={() => download(url2, 'url2')}>下载2</Button>
      <Button onClick={() => download(url3)}>下载3</Button>
      <Button onClick={() => download(blob1, 'blob1.png')}>下载4</Button>
      <Button onClick={fetchLoad}>测试下载</Button>
    </div>
  );
};

export default Download;
